/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import java.util.*;
/**
 * This node class represents a node in a graph that has both a non-standard
 * number of childern and is backwardly linked. Each node contains a string
 * or category list.
 * @author Reuben Doetsch
 */
public class Node
{
    //parent node
    public Node parent;
    //childern node
    public ArrayList<Node> childern;
    //the category
    String categoryName;

    //this is a list of the probing strings in the query
    public ArrayList<String> probingQueries;
    /**
     * This creates a node with no parents or childern with category cat
     * @param cat the category cat
     */
    public Node(String cat)
    {
        categoryName=cat;
        parent=null;
        childern=new ArrayList();
        probingQueries=new ArrayList<String>();
    }


    /**
     * This creates a node with the specfied parent.
     * @param cat the specfied category for the new node
     * @param parent the specifed parent of the node
     */
    public Node(String cat,Node parent)
    {
        categoryName=cat;
        this.parent=parent;
        childern=new ArrayList();
        probingQueries=new ArrayList<String>();
    }

    /**
     * This creates a node with the specfied parent, childern and category
     * @param cat the specfied category of the node
     * @param parent the specfied parent of the node
     * @param childs the specfied childenr of the node
     */
    public Node(String cat,Node parent, ArrayList<Node> childs)
    {
        categoryName=cat;
        this.parent=parent;
        childern=childs;
        probingQueries=new ArrayList<String>();
    }

    /**
     * Returns true if this ia  leaf node
     * @return true is leaf node
     */
    public boolean isLeafNode()
    {
        return childern.isEmpty();
    }

    /**
     * Returns the category name
     * @return
     */
    public String toString()
    {
        String temp= "Node Name: "+ categoryName;
        temp+="\nProbing Queries\n";
        for(String a:probingQueries)
            temp+= " "+ a;
        return temp;
    }
    
}
